package com.bluedot.web.actions;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.InputStream;

import com.opensymphony.xwork2.ActionSupport;

public class UpData extends ActionSupport {

	private String contentType;
	private File upload;
	private String fileName;
	private String caption;

	public String getUploadContentType() {
		return contentType;
	}

	public void setUploadContentType(String contentType) {
		this.contentType = contentType;
	}

	public File getUpload() {
		return upload;
	}

	public void setUpload(File upload) {
		this.upload = upload;
	}

	public String getUploadFileName() {
		return fileName;
	}

	public void setUploadFileName(String fileName) {
		this.fileName = fileName;
	}

	public String getCaption() {
		return caption;
	}

	public void setCaption(String caption) {
		this.caption = caption;
	}

	public String execute() throws Exception {

		System.out.println(fileName);
		System.out.println(contentType);

		InputStream is = new FileInputStream(upload);
		FileOutputStream os=new FileOutputStream("D:/picture/"+this.fileName);
		System.out.println("<<<<<<<<<" + is.available());
		byte[] result = new byte[is.available()];
		System.out.println("path="+upload.getPath());
		is.read(result);
		os.write(result);
		return SUCCESS;
	}
}
